package com.ipet.modules.sys.controller;

import java.util.Arrays;
import java.util.Date;
import java.util.Map;

import com.ipet.common.utils.PageUtils;
import com.ipet.common.utils.R;
import com.ipet.modules.sys.entity.PetCaseEntity;
import com.ipet.modules.sys.service.PetCaseService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;



/**
 * 宠物病例表
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2018-04-23 15:39:03
 */
@RestController
@RequestMapping("sys/petcase")
public class PetCaseController{
    @Autowired
    private PetCaseService petCaseService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:petcase:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = petCaseService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("sys:petcase:info")
    public R info(@PathVariable("id") Integer id){
			PetCaseEntity petCase = petCaseService.selectById(id);

        return R.ok().put("petCase", petCase);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("sys:petcase:save")
    public R save(@RequestBody PetCaseEntity petCase){
        petCase.setCreateTime(new Date());
			petCaseService.insert(petCase);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("sys:petcase:update")
    public R update(@RequestBody PetCaseEntity petCase){
			petCaseService.updateById(petCase);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("sys:petcase:delete")
    public R delete(@RequestBody Integer[] ids){
			petCaseService.deleteBatchIds(Arrays.asList(ids));

        return R.ok();
    }

}
